﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WMH_Project
{
    public class Node
    {
        public Node()
        {
            random = new Random();
        }

        private List<Edge> edges;
        private int numberOfEdges;

        public int NumberOfEdges
        {
            get { return numberOfEdges; }
            set { numberOfEdges = value; }
        }

        public List<Edge> Edges
        {
            get { return edges; }
            set { edges = value; }
        }

        override public String ToString()
        {
            return null;
        }

    

        private Random random;

    }

    class NodeX : Node
    {
        public NodeX(List<Edge> le)
        {
            Edges = le;
            NumberOfEdges = le.Count;
        }
        public NodeX(System.IO.StreamReader sr)
        {


            String line = sr.ReadLine();
            String[] elems = line.Split(' ');

            NumberOfEdges = int.Parse(elems[0]);
            Edges = new List<Edge>(NumberOfEdges);
            for (int i = 0; i < NumberOfEdges; i++)
                Edges.Add( new Edge(sr) );
        }

        public override String ToString()
        {
            String ret;
            ret = NumberOfEdges.ToString() + Environment.NewLine;
            for (int i = 0; i < NumberOfEdges; i++)
                ret += Edges[i].ToString();
            return ret;
        }

    }

    public class NodeY : Node
    {
        public NodeY(System.IO.StreamReader sr)
        {
            Edges = null;
        }

    }

    public class Edge
    {

        public static int compare(Edge x, Edge y)
        {
            if (x.cost > y.cost)
                return 1;
            if (x.cost == y.cost)
                return 0;
            if (x.cost < y.cost)
                return -1;
            return 0;
        }
        public Edge(int c,int e)
        {
            cost = c;
            endID = e;
        }
        public Edge(System.IO.StreamReader sr)
        {
            String line = sr.ReadLine();
            String[] elems = line.Split(' ');
            cost = int.Parse(elems[0]);
            endID = int.Parse(elems[1]);

        }
        public override String ToString()
        {
            return cost.ToString() + " " + endID.ToString() + Environment.NewLine;
        }

        public int cost;
        public int endID;


    }
}
